#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:Charles.chen
# createDate:2017/9/22
# Title:
# Tip:
from flask import render_template, redirect, request, url_for, flash, session
from flask_login import login_user, logout_user, login_required, current_user
from app.toolkit import commonUtil
from app.system import systemService
import json
from . import netBp, internetService

@netBp.route("/network", methods=['GET'])
def goNetwork():
    data = {}
    serverConfig = systemService.getServerConfig()
    data["server"] = serverConfig
    return render_template("network/network.html", data=json.loads(json.dumps(data)))

@netBp.route("/wifiList", methods=['GET'])
def getWifiList():
    wifiList = internetService.getAPSList()
    wifiList = ['wifi1', 'wifi2', 'wifi3', 'wifi4', 'wifi5']
    return json.dumps(wifiList)

# 链接wifi
@netBp.route("/wifiConnect", methods=['POST'])
def connectWifi():
    post_data = json.loads(request.data)
    address = post_data["name"]
    port = post_data["pwd"]
    # result = internetService.setAPSWifi(address,port)
    return commonUtil.buildSucc("ok")
    pass

@netBp.route("/checkInternet", methods=['POST'])
def checkInternet():
    post_data = json.loads(request.data)
    address = post_data["server_name"]
    port = post_data["ip_port"]
    # res =True || False
    res = internetService.checkInternet(address)
    return commonUtil.buildSucc(res)






if __name__ == '__main__':
    pass


